﻿@page "/Scheduler/Customization/RestrictUserActions"

<DemoPageSectionComponent Id="Scheduler-Customization-RestrictUserActions">
    <DemoChildContent>
        <style>
            .caption-item {
                opacity: 1 !important;
                padding-right: 12px;
            }
        </style>
        <DxScheduler @bind-StartDate="@StartDate"
                     DataStorage="@DataStorage"
                     GroupType="SchedulerGroupType.Resource"
                     VisibleResourcesDataSource="VisibleResources"
                     AllowCreateAppointment="@AllowCreateAppointment"
                     AllowDeleteAppointment="@AllowDeleteAppointment"
                     AllowEditAppointment="@AllowEditAppointment"
                     AllowDragAppointment="@AllowDragAndResizeAppointment"
                     AllowResizeAppointment="@AllowDragAndResizeAppointment"
                     AllowDragAppointmentBetweenResources="@AllowDragAppointmentBetweenResources"
                     ShowAppointmentTooltip="@ShowAppointmentTooltip"
                     CssClass="demo-sc-size">
            <DxSchedulerDayView DayCount="1" ShowWorkTimeOnly="true"></DxSchedulerDayView>
        </DxScheduler>
    </DemoChildContent>
    <OptionsContent>
        <DxToolbar ItemRenderStyleMode="ToolbarRenderStyleMode.Plain">
            <Items>
                <DxToolbarItem CssClass="caption-item" Text="Enable/Disable User Actions:" Enabled="false" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="Edit" @bind-Checked="@AllowEditAppointment" Tooltip="Allow Edit Operations" IconCssClass="dx-icon-toolbar icon-edit" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="Create" @bind-Checked="@AllowCreateAppointment" Tooltip="Allow Insert Operations" IconCssClass="dx-icon-toolbar icon-add" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="Delete" @bind-Checked="@AllowDeleteAppointment" Tooltip="Allow Delete Operations" IconCssClass="dx-icon-toolbar icon-delete" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="Drag" @bind-Checked="@AllowDragAndResizeAppointment" Tooltip="Allow Drag & Drop Operations" IconCssClass="dx-icon-toolbar icon-drag-and-sizing" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="DragBetweenResources" @bind-Checked="@AllowDragAppointmentBetweenResources" Tooltip="Allow Drag Operations between Resources" IconCssClass="dx-icon-toolbar icon-drag-appointment-btw-resources" />
                <DxToolbarItem CssClass="me-2 p-0" GroupName="ShowAppointmentTooltip" @bind-Checked="@ShowAppointmentTooltip" Tooltip="Allow Tooltip Display Operations" IconCssClass="dx-icon-toolbar icon-tooltip" />
            </Items>
        </DxToolbar>
    </OptionsContent>

    @code {
        DateTime StartDate { get; set; } = DateTime.Today;

        bool AllowCreateAppointment { get; set; } = false;
        bool AllowEditAppointment { get; set; } = false;
        bool AllowDeleteAppointment { get; set; } = false;
        bool AllowDragAndResizeAppointment { get; set; } = false;
        bool AllowDragAppointmentBetweenResources { get; set; } = false;
        bool ShowAppointmentTooltip { get; set; } = false;

        DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
            AppointmentsSource = ResourceAppointmentCollection.GetAppointments(),
            AppointmentMappings = new DxSchedulerAppointmentMappings()
            {
                Type = "AppointmentType",
                Start = "StartDate",
                End = "EndDate",
                Subject = "Caption",
                AllDay = "AllDay",
                Location = "Location",
                Description = "Description",
                LabelId = "Label",
                StatusId = "Status",
                RecurrenceInfo = "Recurrence",
                ResourceId = "ResourceId"
            },
            ResourcesSource = ResourceCollection.GetResourcesForGrouping(),
            ResourceMappings = new DxSchedulerResourceMappings()
            {
                Id = "Id",
                Caption = "Name",
                BackgroundCssClass = "BackgroundCss",
                TextCssClass = "TextCss"
            }
        };
        List<Resource> VisibleResources = ResourceCollection.GetResources().Take(2).ToList();
    }
</DemoPageSectionComponent>
